<?php
/**
 * XmlRpc编码数组
 *
 * @version $Id: XmlRpcArrayEncoder.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.rai.format.xmlrpc.encoder
 * @since 0.0.3
 */
class XmlRpcArrayEncoder extends AbstractXmlRpcEncoder {
	public function asDOM() {
		$document = new DOMDocument("1.0", $this->getCharset());
		$arrayElement = $document->appendChild($document->createElement("array"));
		$dataElement = $arrayElement->appendChild($document->createElement("data")); 
		foreach ($this->getVar() as $name=>$value) {
			$valueElement = $dataElement->appendChild($document->createElement("value"));
			$valueElement->appendChild($document->importNode(XmlRpcHelper::getEncoder($value, $this->getCharset())->asDOM()->firstChild, true));
		}
		return $document;		
	}
}

?>